import React,{useState} from 'react';
import {Modal,Form} from 'antd';
import Css from '../../../../assets/css/pc/member/address/index.css';
function hoc(WidthComponent){
    return function useHoc(props){
        const [isModal,setIsModal] = useState(false);
        const { confirm } = Modal;
        const [form] = Form.useForm();

        //modal开关
        const addAddress = ()=>{
            setIsModal(true)
        }
        //弹窗取消
        const onCancel = ()=>{
            setIsModal(false);
        }
        ////弹窗提交
        const onOk = () => {
            form.validateFields().then((values) => {
                    console.log('Received values of form: ', values);
                    setIsModal(false);
                }).catch((info) => {
                   console.log('Validate Failed:', info);
                });
        }
        //删除地址
        const editDelete = ()=>{
            confirm({
                title: '确定要删除吗？',
                style:{
                    borderRadius:10,
                    overflow: 'hidden' ,
                    paddingBottom:0,
                    textAlign: 'center',
                },
                bodyStyle:{
                    padding:26,
                },
                width:300,
                icon:null,
                className:Css['editDelete'],
                centered:true,
                maskClosable:true,
                cancelText: '取消',
                okText: '确定',
                onOk() {
                    console.log('OK');
                },

                onCancel() {
                    console.log('Cancel');
                },
            });
        }
        // //分页
        // const pageOnChange = (pageNumber)=>{
        //     console.log('Page: ', pageNumber);
        // }
        let newProps={
            form:form,
            isModal:isModal,
            onOk:onOk.bind(this),
            onCancel:onCancel.bind(this),
            addAddress:addAddress.bind(this),
            editDelete:editDelete.bind(this)
            //pageOnChange:pageOnChange.bind(this),
        }
        return (
            <WidthComponent {...props} {...newProps}/>
        )
    }
}
export default hoc;